﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Wicresoft.SMS.Data;

namespace Wicresoft.SMS.Web
{
    public class OnlyCheckVisibleImpIAuthorise : IAuthorise
    {
        AuthorisedMetadataModel _model;

        IUserRoleService _service = DependencyInjectFacotry.CreateUserRoleService();

        public AuthorisedMetadataModel model
        {
            get
            {
                return _model;
            }
            set
            {
                _model = value;
            }
        }

        //TODO : templatly comments
        public bool IsVisible
        {
            get
            {
                //long value = 0;
                //long[] values = _service.GetRolesValueForUser(_model.User);
                //foreach (long v in values)
                //    value |= v;
                //if ((value & (long)_model.Flag) != (long)_model.Flag)
                //    return false;
                return true;
            }
        }

        public bool IsEnable
        {
            get { throw new NotImplementedException(); }
        }
    }

    public class OnlyCheckEnableImpIAuthorise : IAuthorise
    {
        AuthorisedMetadataModel _model;
        public AuthorisedMetadataModel model
        {
            get
            {
                return _model;
            }
            set
            {
                _model = value;
            }
        }

        IUserRoleService _service = DependencyInjectFacotry.CreateUserRoleService();

        public bool IsVisible
        {
            get { return true; }
        }

        public bool IsEnable
        {
            //TODO : templatly comments
            get
            {
                //long value = 0;
                //long[] values = _service.GetRolesValueForUser(_model.User);
                //foreach (long v in values)
                //    value |= v;
                //if ((value & (long)_model.Flag) != (long)_model.Flag)
                //    return false;
                return true;
            }
        }
    }
}